package com.dc.project_java.test.news;

import com.dc.base.network.NetworkApi;
import com.dc.base.network.RequestCallback;
import com.dc.base.utils.RxJavaUtil;
import com.dc.project_java.test.TestApiService;
import com.dc.project_java.test.utils.Constant;

import io.reactivex.disposables.Disposable;

public class NewsRepository {


    public Disposable getNews(RequestCallback<NewsBean> callback) {
        TestApiService service = NetworkApi.createService(TestApiService.class, TestApiService.BASE_URL);
        return service.news().compose(RxJavaUtil.observableToMain())
                .subscribe(callback::onSuccess, throwable -> callback.onFailure(Constant.FAIL_CODE, throwable.getMessage()));
    }
}
